package com.gelsanalyzer.application;

import java.beans.*;

import org.apache.log4j.*;

import com.gelsanalyzer.business.*;
import com.gelsanalyzer.mvc.controller.*;
import com.gelsanalyzer.mvc.model.*;
import com.gelsanalyzer.mvc.view.*;

public class CourseSelectorController extends AbstractController {
    private static final Logger log = Logger
        .getLogger(CourseSelectorController.class);

    public CourseSelectorController(IView view, AbstractModel model) {
        super(view, model);
        log.info("Just finished constructing...");
    }

    public void propertyChange(PropertyChangeEvent evt) {
        log.info("propertyChange PropertyName=" + evt.getPropertyName());
        if ( evt.getPropertyName().equals(IController.APP_SELECTED_A_DEPARTMENT) ) {
            setModelProperty(IController.APP_SELECTED_A_DEPARTMENT,
                new CourseHome().findByDepartmentExample((Department) evt
                    .getNewValue()));
        }else {
            super.propertyChange(evt);
        }
    }

    public void modelPropertyChange(PropertyChangeEvent event) {
        super.propertyChange(event);
        log
            .info("About to call the concrete view.modelPropertyChange(event)...");
        view.modelPropertyChange(event);
    }
}
